package itdfq.ydd.Creational_Pattern.jiandangongchang;


public class FruitFactory {
    public static Fruit productFruit(String name)throws Exception{
        if (name.equals("车厘子")){
            System.out.println("生产车厘子。。。");
            return  new Cherry();
        }else if(name.equals("香蕉")){
            System.out.println("生产香蕉。。。。。");
            return new Banana();
        }else{
            throw new Exception("暂时无法生产。。。");
        }
    }
}
